The Wilcoxon Signed-Rank Test is a non-parametric statistical hypothesis test used to compare two related samples, matched samples, or repeated measurements on a single sample to assess whether their population mean ranks differ. It is an alternative to the paired Student’s t-test when the data does not meet the assumptions required by the latter, specifically normal distribution of differences.
Purpose:
The Wilcoxon Signed-Rank Test is used to compare two related samples, matched samples, or repeated measurements on a single sample to assess whether their population mean ranks differ. It is the non-parametric alternative to the paired t-test.
How it Works:
Each pair of observations is first compared, and the differences are ranked based on their absolute values. Next, each difference is assigned a sign (+ or -) based on the direction of the difference.
The test then sums the ranks for the positive differences and the ranks for the negative differences. The test statistic is based on the smaller of these sums.
Assumptions
The Wilcoxon Signed-Rank Test is based on the following assumptions:
-
Paired Data: The data must be paired, coming from the same participants or closely matched subjects.
-
Ordinal or Continuous Data: The data should be ordinal, interval, or ratio in nature.
-
Symmetry of the Distribution: The distribution of the differences between pairs should be symmetric.
Hypotheses
The hypotheses for the Wilcoxon Signed-Rank Test are generally framed as follows:
-
Null Hypothesis (H₀): The median of the differences between the pairs of observations is zero.
-
Alternative Hypothesis (H₁): The median of the differences is not zero.
Interpretation
The significance of the observed \(W\) is evaluated by comparing it to a distribution of \(W\) values expected by chance, which can be obtained from a table of critical values for the Wilcoxon signed-rank test or calculated using an appropriate software function. A small \(W\) value suggests a significant difference between the paired samples.
Example Problem
Suppose a dietitian wants to determine if a new diet reduces the weight of patients. Weigh-ins are conducted before starting the diet and after one month of being on the diet for 6 patients:
-
Weights Before: 200, 220, 180, 195, 210, 230
-
Weights After: 190, 215, 175, 185, 205, 225
Hypotheses:
-
Null Hypothesis (H₀): The median difference in weight before and after the diet is zero.
-
Alternative Hypothesis (H₁): The median difference in weight before and after the diet is not zero.
Calculate Differences and Ranks:
- Calculate differences (Before - After): [10, 5, 5, 10, 5, 5]
- Rank the absolute differences: [3.5, 1.5, 1.5, 3.5, 1.5, 1.5]
- Sum of ranks for positive differences: 13 (since all differences are positive, \(W^+ = W\))
Wilcoxon Signed-Rank Test using Excel:
Wilcoxon Signed-Rank Test using R:
Code
# Weights before and after diet
weights_before <- c(200, 220, 180, 195, 210, 230)
weights_after <- c(190, 215, 175, 185, 205, 225)
# Perform Wilcoxon signed-rank test
wilcox_test <- wilcox.test(weights_before, weights_after, paired = TRUE)
# Print the results
print(wilcox_test)
Wilcoxon signed rank test with continuity correction
data: weights_before and weights_after
V = 21, p-value = 0.03054
alternative hypothesis: true location shift is not equal to 0
Wilcoxon Signed-Rank Test using Python:
Code
from scipy.stats import wilcoxon
# Weights before and after diet
weights_before = [200, 220, 180, 195, 210, 230]
weights_after = [190, 215, 175, 185, 205, 225]
# Perform Wilcoxon signed-rank test
w_statistic, p_value = wilcoxon(weights_before, weights_after)
# Print the results
print("Wilcoxon statistic:", w_statistic, "P-value:", p_value)
Wilcoxon statistic: 0.0 P-value: 0.03125
This method is crucial for research in fields like medicine and psychology, where matched pairs or repeated measures are common.